package appconfig

import (
	"fmt"
	"github.com/spf13/viper"
)

type AppConfig struct {
	Mysql
	Redis
	QiNiuYun
}

type Mysql struct {
	Host     string
	Port     int
	User     string
	Password string
	Database string
}

type Redis struct {
	Host     string
	Port     int
	Password string
}

type QiNiuYun struct {
	AccessKey string
	SecretKey string
	Bucket    string
	Url       string
}

var AppConf AppConfig

func Init() {
	viper.SetConfigFile("../appconfig/config.yaml")
	viper.ReadInConfig()
	err := viper.Unmarshal(&AppConf)
	if err != nil {
		panic(err)
	} else {
		fmt.Println("动态配置读取成功:", AppConf)
	}
}
